package com.jsmile.cloud.accountcenter.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 支付类型(枚举)
 *
 * @author Morily
 */
@Getter
@AllArgsConstructor
public enum PayTypeEnum {

    WX_JS(1, "微信小程序支付"), WX_H5(2, "微信h5支付"), WX_APP(3, "微信app支付"), WX_FZ(4, "微信分账支付"), WX_AUTH_CODE(5, "微信条码支付"), ZFB_H5(10, "支付宝h5支付"), ZFB_APP(11, "支付宝APP支付"),
    ZFB_MINI_APP(12, "支付宝小程序支付"), ZFB_FZ(13, "支付宝分账支付"), ZFB_AUTH_CODE(14, "支付宝条码支付"), UNKONW(0, "未知"),;

    /**
     * 值
     */
    private int value;
    /**
     * 名称
     */
    private String name;

    public static boolean hasWxPay(int payType) {
        return 1 == payType || 2 == payType || 3 == payType || 4 == payType || 5 == payType;
    }

    public static boolean hasZfbPay(int payType) {
        return 10 == payType || 11 == payType || 12 == payType || 13 == payType || 14 == payType;
    }

    /**
     * 根据value获取 名称
     */
    public static PayTypeEnum nameOf(int value) {
        PayTypeEnum type = null;
        for (PayTypeEnum rt : PayTypeEnum.values()) {
            if (rt.getValue() == value) {
                type = rt;
                break;
            }
        }
        return type;
    }
}
